home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Will it be auto-deleted?
- Date: Tue, 20 Feb 1996 16:01:08 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <3129E234.1C06089B@intellektik.informatik.th-darmstadt.de>
- References: <1996Feb20.110314.46035@yogi.urz.unibas.ch>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3 sun4m)
-
- Song Jin wrote:
- >
- > I have a question:
- >
- > void myfunction(void)
- > {
- > double *mypointer = new double[100];
- >
- > .....
- >
- > }
- >
- > The mypointer and the buffer it pointed will be auto-deleted after returned
- > from myfunction, am I right?
- >
-
- No -- only the memory for the pointer is released.
- Thus you have to destroy the array via 'delete[] mypointer'.
- However if you declare the array as auto-variable residing
- on the stack, e.g.:
-
- double mypointer[100];
-
- the appropriate memory will be released automatically at the
- end of the function.
-
- Enno
-